import { BookModel } from '../../models/book.js'
import {random} from '../../utils/common.js'
const bookModel = new BookModel()

Page({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    books: [],
    searching:false,
    more: 0,
  },
  onLoad: function () {
    bookModel.getHotList()
      .then(res => {
        console.log(res)
        this.setData({
          books: res
        })
      }
    )
  },
  onSearching(){
    this.setData({
      searching: true
    })
  },
  onCancel(){
    this.setData({
      searching: false
    })
    wx.pageScrollTo({
      scrollTop: 0,
      duration: 0
    })
  },
  onReachBottom(){
    this.setData({
      more: random(16)
    })
  }
})
